package com.yxx.strategy.context;

import com.yxx.enums.LikeTypeEnum;
import com.yxx.strategy.LikeStrategy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 点赞策略上下文
 * @author yuxiangxun
 * @date 2025/2/8
 * @apiNote
 */
@Service
public class LikeStrategyContext {
    @Resource
    private Map<String, LikeStrategy> likeStrategyMap;

    /**
     * 点赞策略
     * @param likeType 点赞类型
     * @param typeId 类型id
     */
    public void executeLikeStrategy(LikeTypeEnum likeType, Integer typeId){
        LikeStrategy likeStrategy = likeStrategyMap.get(likeType.getStrategy());
        likeStrategy.like(typeId);
    }
}
